/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tos.dekker;

import org.jdesktop.application.FrameView;
import tos.TosView;

/**
 *
 * @author Milos
 */
public class Dekker {

    public Dekker(FrameView parent) {
        Brojac brojac = new Brojac(0);
        Variables vars = new Variables();
        
        int prviPovecavac = Integer.parseInt(((TosView)parent).getPrviPovecavac());
        int drugiPovecavac = Integer.parseInt(((TosView)parent).getDrugiPovecavac());
        Processes p1 = new Processes(vars, 0, brojac, prviPovecavac, parent);
        Processes p2 = new Processes(vars, 1, brojac, drugiPovecavac, parent);

        ((TosView)parent).appendOutput("Broj je " + brojac.getBroj() + "\n");
        p1.start();
        p2.start();

        try {
            p1.join();
            p2.join();
        } catch (InterruptedException ex) {
            System.out.println("Erorr!!" + ex.toString());
        }
        
        ((TosView)parent).appendOutput("Broj je " + brojac.getBroj() + "\n");
    }
}
